package collection;

import java.util.ArrayList;
import java.util.List;

public class ListTest {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("一");
        list.add("二");
        list.add("三");
        list.add("四");

        System.out.println(list);
        String str = list.get(2);
        System.out.println(str);
        for (int i = 0; i < list.size(); i++) {//for循环遍历
            str = list.get(i);
            System.out.println(str);
        }

        System.out.println(list);
        String old = list.set(2, "six");
        System.out.println(old);
        System.out.println(list);
        System.out.println(old);
    }
}
